using System;
using System.Collections.Generic;
using System.Text;
using System.Reflection;
using System.IO;
using Zsa.Reflection.Discovery;

namespace Zsa.Emulation.Util
{
    public static class ReflectionHelper
    {



        /// <summary>
        /// Finds the types.
        /// </summary>
        /// <param name="criteria">The criteria.</param>
        /// <returns></returns>
        public static IList<Type> FindTypes(TypeSearchCriteria criteria)
        {
            TypeSearch _Search = new TypeSearch(criteria);
            return _Search.FindTypes();
        }

        /// <summary>
        /// Searches the specified assembly for types 
        /// using the specified criteria.
        /// </summary>
        /// <param name="assembly">The assembly.</param>
        /// <param name="criteria">The criteria.</param>
        /// <returns></returns>
        public static IList<Type> FindTypes(
            Assembly assembly,
            TypeSearchCriteria criteria)
        {
            TypeSearch _Search = new TypeSearch(criteria);
            return _Search.FindTypes(new Assembly[] { assembly });
        }

        /// <summary>
        /// Searches all assemblies for types 
        /// using the specified criteria.
        /// </summary>
        /// <param name="criteria">The criteria.</param>
        /// <returns></returns>
        public static IList<Type> FindTypes(
            params TypeSearchParameter[] criteria)
        {
            TypeSearch _Search = new TypeSearch(
                new TypeSearchCriteria(criteria));
            return _Search.FindTypes();
        }


        //public static IList<Type> FindAllDerived(IList<Assembly> assemblies)
        //{
        //}


        //private static IList<Assembly> GetPluginAssemblies()
        //{
        //    string _FilePath = Path.GetDirectoryName(
        //        typeof(Zsa.Emulation.NesMachine).Assembly.Location) + "\\pluggin";

            
        //}

    }
}
